package com.jiangyg.mall.order.service;

import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.order.dao.OrderReturnReasonDao;
import com.jiangyg.mall.order.dto.OrderReturnReasonDTO;
import com.jiangyg.mall.order.entity.OrderReturnReason;
import com.jiangyg.mall.order.vo.OrderReturnReasonVO;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OrderReturnReasonServiceImpl extends BaseServiceImpl<OrderReturnReasonDao, OrderReturnReason> implements OrderReturnReasonService {

    @Autowired
    public OrderReturnReasonServiceImpl(OrderReturnReasonDao orderReturnReasonDao) {
        super(orderReturnReasonDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<OrderReturnReasonVO> selectPagination(Pagination<OrderReturnReasonVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, OrderReturnReasonVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(OrderReturnReasonDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public OrderReturnReasonVO selectById(Long orderReturnReasonId) throws Exception {
        return this.executeSelectById(orderReturnReasonId, OrderReturnReasonVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> orderReturnReasonIds) {
        return this.baseMapper.deleteBatchIds(orderReturnReasonIds) > 0;
    }

}
